// renderer/src/router/index.ts
import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
import Layout from '@renderer/Layout/index.vue'

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    redirect: { name: 'Test' },
    // component: () => import('@renderer/views/Test.vue'),
    // name: 'Test',
    meta: {
      title: '首页'
    }
  },
  {
    path: '/home',
    component: Layout,
    meta: {
      title: 'home页面'
    },
    children: [
      // 当 /user/:id 匹配成功
      // UserHome 将被渲染到 User 的 <router-view> 内部
      {
        path: 'home',
        name: 'Home',
        meta: {
          title: 'home页面'
        },
        component: () => import('@renderer/views/home.vue')
      },
      {
        path: 'about',
        meta: {
          title: 'About页面'
        },
        name: 'About',
        component: () => import('@renderer/views/about.vue')
      },
      {
        path: '/test',
        component: () => import('@renderer/views/Test.vue'),
        name: 'Test',
        meta: {
          title: '首页',
          hidden: true
        }
      }

      // ...其他子路由
    ]
  },
  {
    path: '/chart',
    redirect: { name: 'BarChart' },
    component: Layout,
    // component: () => import('@renderer/views/Test.vue'),
    // name: 'Test',
    meta: {
      title: '图表页面'
    },
    children: [
      {
        path: 'echarts',
        meta: {
          title: 'BarChart页面'
        },
        name: 'BarChart',
        component: () => import('@renderer/views/Echarts/index.vue')
      }
    ]
  }
]
const router = createRouter({
  history: createWebHashHistory(),
  routes
})
export default router
